package edu.pku.sei.modeler.uml.commands.umlclass;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.uml.Kernel.PackageMerge;
import edu.pku.sei.modeler.model.uml.Kernel.UMLPackage;
import edu.pku.sei.modeler.uml.commands.ConnectionModelDeleteCommand;

public class UMLPackageMergeDeleteCommand extends ConnectionModelDeleteCommand {

	public UMLPackageMergeDeleteCommand(MetaModelElement connectionModel,
			MetaModelElement sourceModel, MetaModelElement targetModel) {
		super(connectionModel, sourceModel, targetModel);
	}

	@Override
	public boolean canExecute() {
		if (sourceModel instanceof UMLPackage) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public void execute() {
		PackageMerge packageMerge = (PackageMerge) this.connectionModel;
		UMLPackage sourcePackage = (UMLPackage) this.sourceModel;
		sourcePackage.getPackageMerge().remove(packageMerge);
	}

	@Override
	public void undo() {
		PackageMerge packageMerge = (PackageMerge) this.connectionModel;
		UMLPackage sourcePackage = (UMLPackage) this.sourceModel;
		sourcePackage.getPackageMerge().add(packageMerge);
	}

}
